package javaTest;

import javax.smartcardio.Card;
import java.util.*;

import static java.util.Collections.swap;

public class Heap {
    public int findKthLargest(int []nums,int k){
        PriorityQueue<Integer> heap=new PriorityQueue<>();
        for(int num:nums){
            if(heap.size()<k)
                heap.add(num);
            //填满之后
            else if(heap.peek()<num){
                heap.poll();
                heap.add(num);
            }
        }
        return heap.poll();
    }


    //优先级队列
    public static void main6(String[] args) {
        int a=10;
        int b=20;
        System.out.println(a>b);
        System.out.println(a<b);
        System.out.println(a==b);
    }//比较
    //equals方法
//    public void Card(int rank, String suit){
//        this rank=rank;
//        this suit=suit;
//    }
//    public boolean equals(Object o){
//        if (this ==o) {
//            return true;
//        }
//        if(o==null||o instanceof Card){
//            return false;
//        }
//        Card c=(Card)o;
//        return rank==c.rank&&suit.equals(c.suit);
//    }







    //直接插入排序

}
